package cn.piggy.gateway.sdk.application;

import cn.piggy.gateway.sdk.config.GatewaySDKServiceProperties;
import cn.piggy.gateway.sdk.domain.service.GatewayCenterService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

@Component
public class GatewayEventApplication implements ApplicationListener<ContextRefreshedEvent> {
    private final Logger logger = LoggerFactory.getLogger(GatewayEventApplication.class);
    @Resource
    private GatewaySDKServiceProperties properties;
    @Resource
    private GatewayCenterService gatewayCenterService;
    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        gatewayCenterService.doRegisterEvent(properties.getInterfaceAddress(), properties.getSystemId());
        logger.info("send ------> redis ------> event");
    }
}
